package com.abss.vote.service.impl;

import com.abss.vote.mapper.TableMapper;
import com.abss.vote.model.Table;
import com.abss.vote.service.TableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("tableService")
public class TableServiceImp implements TableService {

    @Autowired
    TableMapper tableMapper;

    @Override
    public List<Table> findTable() {

        List<String> tableList = tableMapper.selectTbale();

        List<Table> table_list = new ArrayList<>();

        for (String tableName: tableList) {
            String chineseName = tableMapper.selectChineseName(tableName);
            Table table = new Table();
            table.setTable_name(tableName);
            table.setTable_description(chineseName);
            table_list.add(table);
        }
       return table_list;
    }

    @Override
    public List<Table> findInformation(String tableName) {

        return tableMapper.selectInformation(tableName);
    }
}
